package com.sky.mapper;

import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface OrderMapper {
    // 插入订单数据
    void insert(Orders orders);
    //修改订单数据
    void update(Orders orders);
    //分页查询订单数据
    List<Orders> pageQuery(OrdersPageQueryDTO ordersPageQueryDTO);
    //根据订单号查询订单
    @Select("select * from orders where id=#{id}")
    Orders getById(Long id);
    //统计各类订单数量
    @Select("select count(status) from orders where status = #{status}")
    Integer countStatus(Integer status);
    @Select("select * from orders where status = #{status} and order_time < #{orderTime}")
    List<Orders> getBystatusAndOrderTime(Orders orders);
    @Select("select sum(amount) from orders where order_time between #{begin} and #{end} and status = #{status}")
    Double getturnoverStatistics(Map map);
    // 统计订单数量
    Integer countByMap(Map map);

}
